<template>
  <div>
    <svg-icon v-if="flag" icon-class="fullscreen" class="screen" @click="clickScreen" />
    <svg-icon v-else icon-class="exit-fullscreen" class="screen" @click="clickScreen" />
  </div>
</template>

<script>
import ScreenFull from 'screenfull'
export default {
  data() {
    return {
      flag: true
    }
  },
  methods: {
    clickScreen() {
      // 判断浏览器是否支持全屏
      if (ScreenFull.isEnabled) { // true  支持全屏
        this.flag = !this.flag
        ScreenFull.toggle()
      } else {
        this.$message.success('您的浏览器不支持开启全屏')
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.screen {
  fill: #fff !important;
  cursor: pointer;
}
</style>
